package com.project.dao.sys;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.project.common.Constants;
import com.project.common.Page;
import com.project.dao.BaseDao;
import com.project.entity.sys.User;

/**
 * UserDao
 * @author
 *
 */
@Repository
public class UserDao extends BaseDao<User>{
	
	/**
	 * 根据用户名获取User对象
	 * @param userName
	 * @return
	 */
	public User getByUsername(String userName){
		String hql = " FROM User t WHERE t.userCode = ? AND t.dr = ?";
		return super.get(hql,userName, Constants.IS_DELETE_NO);
	}
	
	/**
	 * 分页查询用户
	 * @param page
	 * @return
	 */
	public Page<User> queryPage(Page<User> page){
		String hql = "FROM User t ";
		
		return super.queryPageForHql(page, hql);
	}
	
	/**
	 * 查询指定部门下的人员
	 * @param deptCode
	 * @return
	 */
	public List<User> findBydeptCode(String deptCode){
		String hql = " FROM User t WHERE t.dept = ? ";
		return super.find(hql, deptCode);
	}

	
	/**
	 * 
	 * @return
	 */
	public List<User> getUserList() {
		String hql = " FROM User t ";
		return super.find(hql);
	}
}
